With the 'clicked' attribute you can set a script file that is called when the block is powered with redstone. You can use world and origin for your script.
activated="loader.loadScript('xyz.script');";